﻿<?php require_once('Connections/satphp.php'); include('componentes/enviafoto.class.php');?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$idpego=$_GET['aluno'];

 if(@$_FILES['arquivo']['name']) {
	 $idform=$_POST['iddoaluno'];
	 $resultadofoto = enviafoto("arquivo","/imagem.jpg","fotos",200,100,1,"$idform");
  	
$query_RS_fotoperfil = "update aluno set foto='2' where idaluno='$idform';";
$RS_fotoperfil = mysql_query($query_RS_fotoperfil, $satphp) or die(mysql_error());

header("location:aluno-listar.php");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sem título</title>
</head>

<body>

<div>
<form action="?" method="post" enctype="multipart/form-data">
<input name="iddoaluno" type="hidden" value="<?php echo $idpego ?>" />
<table>
	<tr>
    	<td>Escolha uma imagem para a capa</td>
	</tr>
    <tr>
    	<td><input type="file" name="arquivo" id="arquivo"></td>
	</tr>
    <tr>
      <td align="center"><input type="submit" name="enviar foto" id="enviar foto" value="Enviar" /></td>
    </tr>
</table>
<p>&nbsp;</p>
</form>
</div>
<p><a href="aluno-listar.php">Cancelar</a></p>
</body>
</html>